package com.lineage.server.serverpackets;

import com.lineage.server.model.Instance.L1ItemInstance;
import com.lineage.server.model.Instance.L1ItemStatus;

public class S_TradeAddItem extends ServerBasePacket {
  public S_TradeAddItem(L1ItemInstance item, long count, int type) {
    writeC(35);
    writeC(type);
    writeH(item.getItem().getGfxId());
    String name = item.getNumberedViewName(count);
    writeS(name);
    if (!item.isIdentified()) {
      writeC(3);
      writeC(0);
      writeC(7);
      writeC(0);
    } else {
      writeC(item.getBless());
      L1ItemStatus itemInfo = new L1ItemStatus(item);
      byte[] status = itemInfo.getStatusBytes(false).getBytes();
      writeC(status.length);
      byte[] array;
      int length = (array = status).length;
      int i = 0;
      while (i < length) {
        byte b = array[i];
        writeC(b);
        i++;
      } 
    } 
  }
  
  public S_TradeAddItem() {
    writeC(35);
    writeC(1);
    writeH(714);
    writeS("测试物品(55)");
    writeC(0);
  }
  
  public byte[] getContent() {
    return getBytes();
  }
  
  public String getType() {
    return getClass().getSimpleName();
  }
}
